package com.sto.common.handler;

import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * 工厂类
 *
 * @author ChenPeng
 * @since 2022-07-14 22:31
 */
public class Factory {

    private final static Map<String,Handler> STRING_HANDLER_MAP = new HashMap<String,Handler>();

    public static Handler getInvokerStrategy(String string){
        return STRING_HANDLER_MAP.get(string);
    }

    /**
     * 策略类注册方法
     * @param name
     * @param handler
     */
    public static void register(String name, Handler handler) {
        if (StringUtils.isEmpty(name) || null == handler ){
            return;
        }
        STRING_HANDLER_MAP.put(name,handler);
    }

}
